package com.ruoyi.web.controller.yf;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yf.domain.YfImie;
import com.ruoyi.yf.service.IYfImieService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手机序列号Controller
 * 
 * @author XiaoYi...
 * @date 2020-03-17
 * f24a0f69-ee3d-4f0e-b197-977703e11c11
 */
@Controller
@RequestMapping("/yf/imie")
public class YfImieController extends BaseController
{
    private String prefix = "yf/imie";

    @Autowired
    private IYfImieService yfImieService;

    @RequiresPermissions("yf:imie:view")
    @GetMapping()
    public String imie()
    {
        return prefix + "/imie";
    }

    /**
     * 查询手机序列号列表
     * 2609d6b7-3fb9-49da-adc5-b41d00720e46
     */
    @RequiresPermissions("yf:imie:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfImie yfImie)
    {
        startPage();
        List<YfImie> list = yfImieService.selectYfImieList(yfImie);
        return getDataTable(list);
    }

    /**
     * 导出手机序列号列表
     * 9a2e9d7c-5b51-4a80-8cfa-d7a8da376f54
     */
    @RequiresPermissions("yf:imie:export")
    @Log(title = "手机序列号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YfImie yfImie)
    {
        List<YfImie> list = yfImieService.selectYfImieList(yfImie);
        ExcelUtil<YfImie> util = new ExcelUtil<YfImie>(YfImie.class);
        return util.exportExcel(list, "imie");
    }

    /**
     * 新增手机序列号
     * 8f713810-6f77-4f91-82dc-fa117797fbb7
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存手机序列号
     * 3d42bc07-1e5d-444a-aa77-3807845fd212
     */
    @RequiresPermissions("yf:imie:add")
    @Log(title = "手机序列号", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YfImie yfImie)
    {
        return toAjax(yfImieService.insertYfImie(yfImie));
    }

    /**
     * 修改手机序列号
     * 6362c0da-94c4-4a10-b904-8e0537cb3195
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YfImie yfImie = yfImieService.selectYfImieById(id);
        mmap.put("yfImie", yfImie);
        return prefix + "/edit";
    }

    /**
     * 修改保存手机序列号
     * 6bcba49c-c35a-465e-84cc-ccf8beaf9251
     */
    @RequiresPermissions("yf:imie:edit")
    @Log(title = "手机序列号", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YfImie yfImie)
    {
        return toAjax(yfImieService.updateYfImie(yfImie));
    }

    /**
     * 删除手机序列号
     * 39e98645-4d1a-4f45-8724-0931abd5d3ac
     */
    @RequiresPermissions("yf:imie:remove")
    @Log(title = "手机序列号", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yfImieService.deleteYfImieByIds(ids));
    }
}
